/******************************************************************************
 * Copyright (C) 2025 TTLzi.
 * 
 * All Rights Reserved.
 * 
 * @file    w25qxx.h
 *  
 * @par     dependencies
 *			<stdint.h>
 *			<stdio.h>
 * 
 * @author  TTLzi
 * 
 * @brief   W25QXX简易驱动头文件
 * 
 * @version V1.0
 * 
 * @date	2025.09.30
 * 
 * @note    1 tab = 4 spaces
******************************************************************************/
#ifndef __W25QXX_H__
#define __W25QXX_H__
/******************************** Includes ***********************************/
#include <stdint.h>
#include <stdio.h>
/******************************** Includes ***********************************/

/******************************** Defines  ***********************************/
#define			W25Q80				(0xef13)
#define			W25Q16				(0xef14)
#define			W25Q32				(0xef15)
#define			W25Q64				(0xef16)
#define			W25Q128				(0xef17)

#define			W25QXX_WriteEnable				0x06 
#define			W25QXX_WriteDisable				0x04 
#define			W25QXX_ReadStatusReg			0x05 
#define			W25QXX_WriteStatusReg			0x01 
#define 		W25QXX_ReadData					0x03 
#define 		W25QXX_FastReadData				0x0B 
#define 		W25QXX_FastReadDual				0x3B 
#define 		W25QXX_PageProgram				0x02 
#define 		W25QXX_BlockErase				0xD8 
#define 		W25QXX_SectorErase				0x20 
#define 		W25QXX_ChipErase				0xC7 
#define 		W25QXX_PowerDown				0xB9 
#define 		W25QXX_ReleasePowerDown			0xAB 
#define 		W25QXX_DeviceID					0xAB 
#define 		W25QXX_ManufactDeviceID			0x90 
#define 		W25QXX_JedecDeviceID			0x9F 
/******************************** Defines  ***********************************/

/******************************** Declare ************************************/
/******************************** Declare ************************************/

/******************************** Variables **********************************/
/******************************** Variables **********************************/

/******************************** Functions **********************************/
uint8_t		w25qxx_init					(void);
void 		w25qxx_deinit				(void);
void 		w25qxx_sleep				(void);
void 		w25qxx_wakeup				(void);
uint16_t 	w25qxx_read_id				(void);
void 		w25qxx_write_status			(uint8_t status);
uint8_t 	w25qxx_read_status			(void);
void 		w25qxx_wait_busy			(void);
void 		w25qxx_write_enable			(void);
void 		w25qxx_write_disable		(void);
void 		w25qxx_erase_chip			(void);
void 		w25qxx_erase_sector			(uint32_t addr);
void		w25qxx_page_program			(uint32_t addr,
										 uint8_t * pdata,
										 uint16_t size);
void 		w25qxx_write_no_check		(uint32_t addr,
										 uint8_t * pdata,
										 uint16_t size);
void 		w25qxx_write				(uint32_t addr,
										 uint8_t * pdata,
										 uint16_t size);
void 		w25qxx_read					(uint32_t addr,
										 uint8_t * pdata,
										 uint16_t size);
/******************************** Functions **********************************/

#endif // End of __W25QXX_H__
